package com.springboot.demo.entity;

import com.springboot.demo.entity.validate.role.RoleDescriptionGroup;
import com.springboot.demo.entity.validate.role.RoleNameGroup;
import com.springboot.demo.entity.validate.user.IdGroup;
import com.springboot.demo.entity.validate.user.UsernameGroup;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;

/**
 * @author wubc683
 * @desc 用户角色
 * @date 2021-08-16 8:51
 */
@Data
public class Role implements Serializable {
    @NotNull(message = "id不能为null", groups = {IdGroup.class})
    @ApiModelProperty(value = "角色id", required = true)
    private Long id;
    @ApiModelProperty(value = "角色名,6~32位字符", required = true)
    @NotBlank(message = "角色名不能为空", groups = {RoleNameGroup.class})
    @Length(min = 6, max = 32, message = "角色名长度不对",groups = RoleNameGroup.class)
    @Pattern(regexp = "^[a-zA-Z0-9_-\\u4E00-\\u9FA5]{6,32}$", message = "角色名格式错误",
            groups = RoleNameGroup.class)
    private String name;
    @ApiModelProperty(value = "角色描述,最长64位", required = true)
    @NotNull(message = "角色描述不能为null", groups = {RoleDescriptionGroup.class})
    @Length(min = 0, max = 64, message = "角色描述太长", groups = {RoleDescriptionGroup.class})
    private String description;
}
